package com.ms3ds.mineInfo.api.factory;

import com.ms3ds.common.core.domain.R;
import com.ms3ds.mineInfo.api.RemoteMineService;
import com.ms3ds.mineInfo.api.RemoteOreTypeService;
import com.ms3ds.mineInfo.api.domain.Mine;
import com.ms3ds.mineInfo.api.domain.OreType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 矿山信息服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteOreTypeFallbackFactory implements FallbackFactory<RemoteOreTypeService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteOreTypeFallbackFactory.class);

    @Override
    public RemoteOreTypeService create(Throwable throwable)
    {
        log.error("矿山信息服务调用失败:{}", throwable.getMessage());
        return new RemoteOreTypeService()
        {
            @Override
            public R<OreType> getOreTypeByIdForremote(Long oreTypeId) {
                return R.fail("获取矿物"+oreTypeId+"种类信息失败:" + throwable.getMessage());
            }
        };
    }
}
